package com.niit.sparkSql

import java.util.Properties

import org.apache.spark.sql.SparkSession

/**
 * @author gaomj
 * @data 2022/12/12 11:41
 *
 *      我只是有个想法，但没有完全实现
 *      可能因为不会用吧
 *
 */
object action_collect {
  def main(args: Array[String]): Unit ={
    val spark=SparkSession.builder().appName("wc").master("local").getOrCreate()
    val url = "jdbc:mysql://127.0.0.1:3306/school?user=root&password=123456"
    val prop = new Properties()


    val df = spark.read.jdbc(url, "`205817`", prop)


    println(df.show)


    //    println(df.rdd.partitions.size)
    df.createOrReplaceTempView("man")


    import spark.sql
    sql("select * from man where Sex=0").show()
    val man1 = sql("select * from man where Sex=0").count()
    println(man1)




  }


}
